import 'package:flustars_flutter3/flustars_flutter3.dart';
import 'package:flutter/material.dart';
import 'package:ls_work/a_yyt/models/visit_entity.dart';
import 'package:ls_work/res/colors.dart';
import 'package:ls_work/res/gaps.dart';
import 'package:ls_work/res/styles.dart';

class OrgVisitRecordCell extends StatelessWidget {
  final VisitInfo? info;
  final Function()? onTap;
  OrgVisitRecordCell({Key? key, this.info, this.onTap});
  @override
  Widget build(BuildContext context) {
    return Container(
      width: ScreenUtil.getScreenW(context),
      padding: EdgeInsets.fromLTRB(12, 10, 12, 10),
      margin: EdgeInsets.fromLTRB(12, 0, 12, 0),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(8),
      ),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: <Widget>[
              Text(
                '${info?.companyName ?? ''}',
                style: TextStyles.textDark16,
              ),
              Container(
                padding: EdgeInsets.fromLTRB(10, 8, 10, 8),
                decoration: BoxDecoration(
                  color: Colours.app_main,
                  borderRadius: BorderRadius.circular(5),
                ),
                child: GestureDetector(
                  behavior: HitTestBehavior.opaque,
                  onTap: onTap,
                  child: Text(
                    '接待确认',
                    style: TextStyle(color: Colors.white, fontSize: 16),
                  ),
                ),
              ),
            ],
          ),
          Gaps.vGap10,
          _item('来访日期：', '${info?.visitTime ?? ''}'),
          Gaps.vGap10,
          _item('来访机构：', '${info?.orgName ?? ''}'),
          Gaps.vGap10,
          _item('联系人员：', '${info?.contactName ?? ''}'),
          Gaps.vGap10,
          _item('联系电话：', '${info?.contactMobile ?? ''}'),
          Gaps.vGap10,
          _item('来访人数：', '${info?.visitHumanNum}'),
          info?.mealStandardName != null ? Gaps.vGap10 : SizedBox(),
          info?.mealStandardName != null
              ? _item('餐饮标准：', '${info?.mealStandardName}')
              : SizedBox(),
          info?.sourceNames != null ? Gaps.vGap10 : SizedBox(),
          info?.sourceNames != null
              ? _item('协调资源：', '${info?.sourceNames}')
              : SizedBox(),
        ],
      ),
    );
  }

  Widget _item(String title, String content) {
    return Text.rich(TextSpan(children: [
      TextSpan(text: title, style: TextStyles.textGray14),
      TextSpan(text: content ?? '', style: TextStyles.textNormal14),
    ]));
  }
}
